package com.dbxt.teacher.service.impl;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.dbxt.dao.RecordMapper;
import com.dbxt.dao.TeacherMapper;
import com.dbxt.entity.Clerk;
import com.dbxt.entity.ClerkRecord;
import com.dbxt.entity.Record;
import com.dbxt.entity.RecordTeacher;
import com.dbxt.entity.Student;
import com.dbxt.entity.Teacher;
import com.dbxt.entity.Files;
import com.dbxt.teacher.service.TeacherService;

@Service
@Transactional
public class TeacherServiceImpl implements TeacherService {
	@Autowired
	private TeacherMapper teacherMapper;
	@Autowired
	private RecordMapper recordMapper;


	@Override
	public Student selectRecordByStudent(Integer sid) {		
		return teacherMapper.selectRecordByStudent(sid);
	}


	@Override
	public RecordTeacher selectRecordTeacherByTeacher(Integer tid,Integer rid) {
		// TODO Auto-generated method stub
		return teacherMapper.selectRecordTeacherByTeacher(tid,rid);
	}


	@Override
	public boolean updateScoreAndCommitByTeacher(RecordTeacher recordTeacher) {
		// TODO Auto-generated method stub
		return teacherMapper.updateScoreAndCommitByTeacher(recordTeacher);
	}




	@Override
	public int selectCountTeacher(Integer rid) {
		// TODO Auto-generated method stub
		return teacherMapper.selectCountTeacher(rid);
	}


	@Override
	public List<RecordTeacher> selectCountGradeByTeacher(Integer rid) {
		// TODO Auto-generated method stub
		return teacherMapper.selectCountGradeByTeacher(rid);
	}


	@Override
	public boolean updateRecordGrade(Record record) {
		// TODO Auto-generated method stub
		return teacherMapper.updateRecordGrade(record);
	}


	@Override
	public Boolean UpdataRecord(Record record) {
		try {
			record = recordMapper.selectBySid(record.getStudent().getSid());
			record.setStatus("0");
			if (recordMapper.updateByPrimaryKeySelective(record)==1) {
				return true;
			}
			return false;
		} catch (Exception e) {
			e.printStackTrace();
			return false;
		}
	}


	@Override
	public Files selectFile(Integer fid) {
		// TODO Auto-generated method stub
		return teacherMapper.selectFile(fid);
	}


	@Override
	public boolean updateRecordByTeacher(Record record) {
		// TODO Auto-generated method stub
		return teacherMapper.updateRecordByTeacher(record);
	}


	@Override
	public Record selectRecordByStudentUpdate(Integer rid) {
		// TODO Auto-generated method stub
		return teacherMapper.selectRecordByStudentUpdate(rid);
	}


	@Override
	public boolean insertRecordTeacher(RecordTeacher recordTeacher) {
		// TODO Auto-generated method stub
		return teacherMapper.insertRecordTeacher(recordTeacher);
	}


	@Override
	public Student selectForeach(List<Student> students) {
		// TODO Auto-generated method stub
		return teacherMapper.selectForeach(students);
	}


	@Override
	public List<Student> selectStudentList(String gruouping, Integer tid) {
		// TODO Auto-generated method stub
		return teacherMapper.selectStudentList(gruouping, tid);
	}


	@Override
	public ClerkRecord selectClerkRecordByClerk(Integer cid, Integer rid) {
		// TODO Auto-generated method stub
		return teacherMapper.selectClerkRecordByClerk(cid, rid);
	}


	@Override
	public ClerkRecord selectCrid(Integer rid) {
		return teacherMapper.selectCrid(rid);
		
	}


	@Override
	public RecordTeacher selectRtid(Integer rid) {
		return teacherMapper.selectRtid(rid);
		
	}





	@Override
	public boolean updateRtid(RecordTeacher recordTeacher) {
		
		return teacherMapper.updateRtid(recordTeacher);
		
	}


	@Override
	public boolean updateCrid(ClerkRecord clerkRecord) {
		return teacherMapper.updateCrid(clerkRecord);
		
	}


	@Override
	public Student checkResult(Integer sid) {
		// TODO Auto-generated method stub
		return teacherMapper.checkResult(sid);
	}


	@Override
	public Teacher selectTeacher(Integer tid) {
		// TODO Auto-generated method stub
		return teacherMapper.selectTeacher(tid);
	}


	@Override
	public Clerk selectClerk(Integer cid) {
		// TODO Auto-generated method stub
		return teacherMapper.selectClerk(cid);
	}





	


	









	
}
